function VenomDamage takes nothing returns nothing
	local unit target = GetEnumUnit()
	//--
	if IsUnitEnemy(target , udg_TempPlayer) and IsUnitInRangeLoc(target , udg_TempLocation , udg_TempRadius) and not IsUnitType(target , UNIT_TYPE_STRUCTURE) and GetUnitState(target , UNIT_STATE_LIFE) > 0.0 then
		call UnitDamageTarget(udg_TempDamager , target , udg_TempDamage , true , false , ATTACK_TYPE_NORMAL, DAMAGE_TYPE_COLD , WEAPON_TYPE_WHOKNOWS)
		set udg_TempBoolean = true
	endif
	//--
	set target = null
endfunction

function VenomRoutine takes nothing returns nothing
	local timer venomTimer = GetExpiredTimer(  )
	local integer timerId = GetHandleId( venomTimer )
	local unit venomEffect = LoadUnitHandle(udg_HT , timerId , 3 )
	local location venomLocation = GetUnitLoc( venomEffect )
	local real dx = LoadReal( udg_HT , timerId , 4 )
	local real dy = LoadReal( udg_HT , timerId , 5 )
	local real time = LoadReal( udg_HT , timerId , 6 )
	local boolean end = false
	local real maxTime = LoadReal(udg_HT , timerId , 7)
	//--
	//pick看看
	set udg_TempDamager = venomEffect
	set udg_TempPlayer = GetOwningPlayer(venomEffect)
	set udg_TempDamage = 20.0
	set udg_TempRadius = 50.0
	set udg_TempLocation = venomLocation
	set udg_TempBoolean = false
	set bj_wantDestroyGroup = true
	call ForGroupBJ(GetUnitsInRangeOfLocMatching(udg_TempRadius+70.0, udg_TempLocation , null) , function VenomDamage)
	//移動子彈
	if not udg_TempBoolean and time < maxTime then
		set time = time + 0.01
		call SaveReal( udg_HT , timerId , 6 , time )
		call SetUnitX( venomEffect , GetUnitX( venomEffect ) + dx )
		call SetUnitY( venomEffect , GetUnitY( venomEffect ) + dy )	
	else
		set end = true
	endif
	if end then
		//摧毀timer
		call PauseTimer( venomTimer )
		call FlushChildHashtable( udg_HT , timerId )
		call DestroyTimer( venomTimer )
		call KillUnit( venomEffect )
	endif
	//--
	set venomTimer = null
	set venomEffect = null
	call RemoveLocation( venomLocation )
	set venomLocation = null
endfunction

function Trig_Venom_Actions takes nothing returns nothing
	local unit dino = GetTriggerUnit()
	local player dinoOwner = GetOwningPlayer(dino)
	local location dinoLocation = GetUnitLoc(dino)
	local location targetLocation = GetSpellTargetLoc()
	local real distance = DistanceBetweenPoints(dinoLocation , targetLocation)
	local real angle = AngleBetweenPoints(dinoLocation , targetLocation)
	local real timerInterval = 0.01
	local real speed = 800.0
	local real maxDistance = 1000.0
	local real delta = speed * timerInterval
	local real dx = Cos(angle * bj_DEGTORAD) * delta
	local real dy = Sin(angle * bj_DEGTORAD) * delta
	local unit venomEffect = CreateUnit(dinoOwner , 'e00E' , GetLocationX(dinoLocation) , GetLocationY(dinoLocation) , angle)
	local timer venomTimer = CreateTimer()
	local integer timerId = GetHandleId(venomTimer)
	//--
	call SetUnitX(venomEffect , GetLocationX(dinoLocation) + dx)
	call SetUnitY(venomEffect , GetLocationY(dinoLocation) + dy)
	call SaveUnitHandle(udg_HT , timerId , 3 , venomEffect)
	call SaveReal(udg_HT , timerId , 4 , dx)
	call SaveReal(udg_HT , timerId , 5 , dy)
	call SaveReal(udg_HT , timerId , 6 , 0.0)//目前經過時間
	call SaveReal(udg_HT , timerId , 7 , maxDistance / speed)//最大經過時間
	call TimerStart(venomTimer , timerInterval , true , function VenomRoutine)
	//--釋放空間與清空區域變數
	set dino = null
	set dinoOwner = null
	call RemoveLocation(dinoLocation)
	set dinoLocation = null
	call RemoveLocation(targetLocation)
	set targetLocation = null
	set venomEffect = null
	set venomTimer = null
endfunction

function Trig_Venom_Conditions takes nothing returns boolean
	return GetSpellAbilityId() == 'A00X'
endfunction

function InitTrig_Venom takes nothing returns nothing
    set gg_trg_Venom = CreateTrigger(  )
    call TriggerRegisterAnyUnitEventBJ( gg_trg_Venom, EVENT_PLAYER_UNIT_SPELL_EFFECT )
    call TriggerAddCondition( gg_trg_Venom, Condition( function Trig_Venom_Conditions ) )
    call TriggerAddAction( gg_trg_Venom, function Trig_Venom_Actions )
endfunction